package com.geekchique.runningbuddy.view;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;

import com.geekchique.runningbuddy.activity.Home;
import com.geekchique.runningbuddy.activity.CurrentlyRunningJogMap;
import com.geekchique.runningbuddy.activity.MapOfPastJogs;
import com.geekchique.runningbuddy.activity.PastJogs;
import com.geekchique.runningbuddy.activity.StopClock;
import com.geekchique.runningbuddy.activity.Today;
import com.geekchique.runningbuddy.provider.ActivityID;

public class HomeView  extends LinearLayout {

	private Home activity;

	public HomeView(Home home, ImageButton stopClock, ImageButton diary, Button gotoPastJogsMap, Button goOnAJog) {
		super(home);

		this.activity = home;
		stopClock.setOnClickListener(gotoStopClockListener);
        diary.setOnClickListener(gotoTodayListener);
        gotoPastJogsMap.setOnClickListener(gotoJogMapListener);
        goOnAJog.setOnClickListener(goOnAJogListener);
	}

	private void switchToStopClock() {
	      Intent i = new Intent(activity, StopClock.class);
	      activity.startSubActivity(i, ActivityID.STOPCLOCK);
	}

	private void switchToToday() {
	    Intent i = new Intent(activity, Today.class);
	    activity.startSubActivity(i, ActivityID.TODAYJOGS);
	}

	private void switchToMapOfPastJogs() {
		Intent i = new Intent(activity, MapOfPastJogs.class);
		activity.startSubActivity(i, ActivityID.MAPOFPASTJOGS);
	}


	private void switchToGoOnAJog() {
	    Intent i = new Intent(activity, CurrentlyRunningJogMap.class);
	    activity.startSubActivity(i, ActivityID.JOGMAP);
	}

	private OnClickListener gotoJogMapListener = new OnClickListener()
	{
	  	public void onClick(View v)
	      {
	  		switchToMapOfPastJogs();
	      }
	};

	private OnClickListener gotoStopClockListener = new OnClickListener()
	{
		public void onClick(View v)
		{
			switchToStopClock();
		}
	};

	private OnClickListener gotoTodayListener = new OnClickListener()
	{
	  	public void onClick(View v)
	      {
	  		switchToToday();
	      }
	};

	private OnClickListener goOnAJogListener = new OnClickListener()
	{
		public void onClick(View v)
		{
			switchToGoOnAJog();
		}

	};

}
